<?php 
class messege_controller extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		$this->load->model('messege_model');
	}

	
	function show_my_messege()
	{
	
		$data['rows']=$this->messege_model->ChangeQueryResultToArray( $this->messege_model->get_all_messege() );
		$data['userid']=$this->session->userdata('userid');
		$data['title']="Messages";
		$data['id']='message';
		$this->load->view('header',$data);
		$this->load->view('show_messege_view', $data);
		$this->load->view('footer',$data);
	}
	
	function to_send_messege()
	{
		
		$receiverid=$this->input->get('receiverid');
		$data['rows']=$this->messege_model->ChangeQueryResultToArray($this->messege_model->get_messege($receiverid) );
		$data['receiverid']=$receiverid;
		$data['title']="Messages";
		$data['id']='message';
		$this->load->view('header',$data);
		$this->load->view('send_messege_view',$data);
		$this->load->view('footer',$data);
		
		
	}
	function send_messege()
	{
		$receiverid=$this->input->get('receiverid');
		$content=$this->input->post('content');
		$this->messege_model->create_messege($receiverid,$content);
		
		redirect('notification_controller/send_notice?notice_type=3&receiverid='.(string)($receiverid));
		
		//$str = 'messege_controller/to_send_messege?receiverid='.(string)($receiverid);
		//redirect($str);
	}
	
	
}